package com.wondersgroup.insurance.dnuilearn.viewgroups.viewpager;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;

import com.wondersgroup.insurance.dnuilearn.R;

/**
 * Created by Administrator on 2017/6/20.
 */

public class ViewPagerTransformerActivity extends AppCompatActivity {
    ViewPager pager = null;
    private int[] layouts = {
//            R.layout.welcome1,
//            R.layout.welcome2,
//            R.layout.welcome3


            R.layout.welcome4,
            R.layout.welcome5,
            R.layout.welcome4
    };


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


    setContentView(R.layout.activity_viewpager);
        pager = (ViewPager) findViewById(R.id.pager);

        WelcomePagerAdapter adapter = new WelcomePagerAdapter(getSupportFragmentManager());
//        pager.setPageTransformer(true, new WelcompagerTransformer());
        pager.setPageTransformer(true, new WelcompagerTransformer1());
        pager.setAdapter(adapter);
        pager.setCurrentItem(Integer.MAX_VALUE/2);
    }

/*    class WelcomePagerAdapter extends FragmentPagerAdapter {

        public WelcomePagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            Fragment f = new TranslateFragment();
            Bundle bundle = new Bundle();
            bundle.putInt("layoutId", layouts[position]);
            f.setArguments(bundle );
            return f;
        }

        @Override
        public int getCount() {
            // TODO Auto-generated method stub
            return 3;
        }

    }*/

    class WelcomePagerAdapter extends FragmentPagerAdapter {

        public WelcomePagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            int realPosition = position% layouts.length;
            Fragment f = new TranslateFragment();
            Bundle bundle = new Bundle();
            bundle.putInt("layoutId", layouts[realPosition]);
            f.setArguments(bundle );
            return f;
        }

        @Override
        public int getCount() {
            // TODO Auto-generated method stub
            return Integer.MAX_VALUE;
        }


    }
}
